package admin.code.generator.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import admin.code.generator.App;

/**
*
* @author dw_chenqi
* @date 2016年3月2日下午4:54:12
*/
public class ConfigUtils {

	private static Properties props = new Properties();

	public static String get(String key) {
		return props.getProperty(key);
	}

	public static void loadCfgFile(String cfgFile) {
		try {
			System.err.println(cfgFile);
			props.load(App.class.getClassLoader().getResourceAsStream(cfgFile));
		} catch (Exception e) {
			e.printStackTrace();
			try {
				props.load(new FileInputStream(cfgFile));
			} catch (IOException e1) {
				e1.printStackTrace();
				System.exit(0);
			}
		}
	}

	/*public static Configuration getInstance() {
		Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
		cfg.setClassForTemplateLoading(CodeGenerator.class, "/templates");
		cfg.setDefaultEncoding("UTF-8");
		cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
		return cfg;
	}*/

}
